

const apiKey = 'af4d388252ce9aa834d562e890ec0620.rbPF47GfJuzOECqc';

function callZhipuAPI(endpoint, data) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: `https://open.bigmodel.cn${endpoint}`,
      method: 'POST',
      header: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${apiKey}`
      },
      data: data,
      success: (res) => {
          resolve(res.data);
      },
      fail: (err) => {
      }
    });
  });
}

module.exports = {
  callZhipuAPI
};
